<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class mgameseries extends MY_Model {

    var $theme_data = array(
        'layout_main' => 'layout',
        'left' => 'include/leftcp',
    );
    public $mytable = "game_series";
    public $primaryKey = "gseries_id";
    public $resCode = "GAME_SERIES";

    function __construct() {
        parent::__construct();
    }

    function field() {
		$fieldData = array();
		$fieldData['game_id'] = 0;
		$fieldData['series_id'] = 0;
		$fieldData['gseries_order'] = 0;
		$fieldData['gseries_time_create'] = 0;
		return $fieldData;
    }
	
	function gets_game($series_id){
		$this->db->join("game","game.game_id = game_series.game_id");
		return $this->mgameseries->gets($series_id,'series_id');
	}
	
	function update_game($game_id = array(), $series_id = 0){
		$this->delete($series_id,'series_id');
		$data = array();
		$i=0;
		if(count($game_id)>0)
		foreach($game_id as $gameid){
			if($gameid >0){
				$data[] = array(
					'game_id'=>$gameid,
					'series_id'=>$series_id,
					'gseries_order'=>$i,
					'gseries_time_create'=>time(),
				);
			}
		}
		if($data)
		$this->db->insert_batch($this->mytable, $data); 
	}
}

?>